<!DOCTYPE html>
<html lang='en'>
  <head>
    <style>{{ css|raw }}</style>
    {{ useCjk ? '<style>td { font-family:sun-extA; }</style>' }}
  </head>
  <body {{ useCjk ? " style='font-family:sun-extA;'" }}>
  <htmlpagefooter name='footer'>
    {% if pdfSig %}
      <div class='footer-block signatures'>
        User's signature:<br><br>
        Witness' name:<br><br>
        Witness' signature:<br><br>
      </div>
    {% endif %}
    <div class='footer-block footer'>
      <p style='font-size:6pt;'>PDF generated with <a href='https://www.elabftw.net'>elabftw</a>, a free and open source lab notebook<br>
      File generated on {DATE d-m-Y} at {DATE H:i}</p>
      <p>{PAGENO} / {nb}</p>
    </div>
  </htmlpagefooter>

  <div id='header'>
    <h1 class='entry-title'>
      {% if entityData.custom_id %}
        <span style='color:#4d4c4c'>{{ entityData.custom_id }}</span>
      {% endif %}
      {{ entityData.title }}
    </h1>
    <div class="entry-meta">
      <p>
        <strong>{{ 'Date'|trans }}:</strong> {{ date }}<br>
        {% if entityData.tags %}
          {% set tags = entityData.tags|split('|') %}
          <strong>{{ 'Tags'|trans }}:</strong>
          {% for tag in tags %}
            <span class='tag'>{{ tag }}</span>
          {% endfor %}<br>
        {% endif %}
        {% if entityData.category_title %}
          <strong>{{ 'Category'|trans }}:</strong> {{ entityData.category_title }}<br>
        {% endif %}
        {% if entityData.status_title %}
          <strong>{{ 'Status'|trans }}:</strong> {{ entityData.status_title }}<br>
        {% endif %}
        <strong>{{ 'Created by'|trans }}:</strong> {{ entityData.fullname }}<br>
      </p>
    </div>
  </div>

  {% if timestamped %}
  <div class="timestamped-block">
    <p>{{ 'This document has been timestamped by %s on %s.'|trans|format(timestamperName, localDate) }}</p>
  </div>
  {% endif %}

{{ body|raw }}

{% if entityData.metadata %}
<section class='no-break no-list-style'>
  {{ entityData.metadata|formatMetadata }}
</section>
{% endif %}

{% if entityData.experiments_links %}
  <section class='no-break'>
    <h3>{% trans %}
      Linked experiment
      {% plural entityData.experiments_links|length %}
      Linked experiments
      {% endtrans %}</h3>

    {% for link in entityData.experiments_links %}
      <p class='pdf-ul'>
        <span style='color:#{{ link.color }}'>{{ link.category_title }}</span> - <a href='{{ linkBaseUrl.experiments }}?mode=view&amp;id={{ link.entityid }}'>{{ link.title }}</a>
      </p>
    {% endfor %}
  </section>
{% endif %}
{% if entityData.items_links %}
  <section class='no-break'>
    <h3>{% trans %}
      Linked resource
      {% plural entityData.items_links|length %}
      Linked resources
      {% endtrans %}</h3>

    {% for link in entityData.items_links %}
      <p class='pdf-ul'>
        <span style='color:#{{ link.color }}'>{{ link.category_title }}</span> - <a href='{{ linkBaseUrl.items }}?mode=view&amp;id={{ link.entityid }}'>{{ link.title }}</a>
      </p>
    {% endfor %}
  </section>
{% endif %}

{% if entityData.steps %}
  <section class='no-break'>
    <h3>{{ 'Steps'|trans }}</h3>
    {% for step in entityData.steps %}
      <p class='pdf-ul'>{{ step.body }}
      {% if step.finished %} ({{ step.finished_time }}){% endif %}
    </p>
    {% endfor %}
  </section>
{% endif %}

{% if includeFiles and entityData.uploads %}
  <section class='no-break'>
    <h3>{% trans %}
      Attached file
      {% plural entityData.uploads|length %}
      Attached files
      {% endtrans %}
    </h3>
    {% for upload in entityData.uploads %}
      <p class='pdf-ul'>{{ upload.real_name }}
      {# add a comment? don't add if it's the default text or if it's null #}
      {% if upload.comment and upload.comment != 'Click to add a comment' %} ({{ upload.comment|nl2br }}){% endif %}
      {# add hash? don't add if we don't have it #}
      {% if upload.hash|length >= 32 %}<br>{{ upload.hash_algorithm }}: {{ upload.hash }}{% endif %}

      {% if upload.base64_thumbnail %}
      {# Note: adding charset to the data string makes it fail #}
        <br><img class='attached-image' src='data:image/jpeg;base64,{{ upload.base64_thumbnail }}' alt='{{ upload.comment|e('html_attr') }}' />
      {% endif %}
      </p>
    {% endfor %}
  </section>
{% endif %}

{% if entityData.comments %}
  <section class='no-break'>
    <h3>{% trans %}
      Comment
      {% plural entityData.comments|length %}
      Comments
      {% endtrans %}
    </h3>
    {% for comment in entityData.comments %}
      <p class='pdf-ul'>On {{ comment.created_at }} {{ comment.fullname }} wrote:<br>{{ comment.comment|nl2br }}</p>
    {% endfor %}
  </section>
{% endif %}

<div id='infoblock'>
  <table class='noborder' role='presentation'>
    <tr>
      <td class='noborder'>
        {# use raw here as this is an mpdf special tag and the url needs to be passed unmodified #}
        <barcode code='{{ url|raw }}' type='QR' class='barcode' size='0.8' error='M' />
      </td>
      <td class='noborder'>
        {% if entityData.elabid %}
          <p class='elabid'>{{ 'Unique eLabID:'|trans }} {{ entityData.elabid }}</p>
        {% endif %}
        {% if locked %}
          <p class='elabid'>
            {{ 'Locked by %s on %s at %s'|trans|format(lockerName, lockDate, lockTime) }}
          </p>
        {% endif %}
        {% if timestamped %}
          <p class='elabid'>
            {{ 'Timestamped by %s on %s at %s'|trans|format(timestamperName, timestampDate, timestampTime) }}
          </p>
        {% endif %}
        <p class='elabid'>Link: <a href='{{ url }}'>{{ url }}</a></p>
        {% if classification != 'None' %}
          <p class='elabid'>Classification: {{ classification }}</p>
        {% endif %}
      </td>
    </tr>
  </table>
</div>

{% if includeChangelog %}
  <h3 id='changelogHeader'>{{ 'Changelog'|trans }}</h3>
  <table class='table' aria-labelledby='changelogHeader'>
    {% include 'changelog-table.html' %}
  </table>
{% endif %}
